<template>
  <div class="fsc-header">
    <div class="fsc-thead" v-if="weekArr">
      <div
        class="fsc-th"
        v-for="(item, index) in weekArr"
        :key="index"
      >
        <!-- @click="scheduleColAll(item, index)" -->
        <span class="tit">
          <span>{{item}}</span>
        </span>
      </div>
    </div>
  </div>
</template>

<script>
import bus from '@/api/bus'
import { mapGetters } from 'vuex'
// import { Options } from '@/utils/constant'
export default {
  props: {
    isEdit: Boolean,
    isCopy: Boolean,
    editShow: Boolean,
    checkboxShow: Boolean,
    allCkb: {
      type: Boolean,
      default: false
    },
    statusTemplate: {
      type: String,
      default: 'schedule'
    },
    seasonCur: {
      type: String,
      default: ''
    },
    checkedAllShow: {
      type: Boolean,
      default: true
    },
    checkedAll: {
      type: Boolean,
      default: false
    },
    // 模板排列，定位、日按顺序排
    appoRepair: {
      type: Boolean,
      default: false
    },
    weekArr: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      // weekOptions: Options.weekOptions
    }
  },
  computed: {
    ...mapGetters(['isShowEditScedule']),
    seasonVal: {
      get() {
        return this.seasonCur
      },
      set(val) {
        this.$emit('update:seasonCur', val)
      }
    },
    checkedAllVal: {
      get() {
        return this.checkedAll
      },
      set(val) {
        this.$emit('update:checkedAll', val)
      }
    }
  },
  created() {
    // console.log('checkbox-show-in Header--created', this.checkboxShow)
  },
  mounted() {
    // console.log('checkbox-show-in Header--mounted', this.checkboxShow)
  },
  methods: {
    // 选择全列
    scheduleColAll(row, index) {
      console.log('you click scheduleColAll', row, row.checkedAll)
      if (this.isEdit && (!row.disable || this.allCkb)) {
        this.$emit('HeaderColAll', { row, index })
        // this.$forceUpdate()
      }
    },
    editTodaySchedule(row, index) {
      // console.log('this.isEdit', this.isEdit)
      // console.log('row.disable', this.disable)
      // console.log('this.allCkb', this.allCkb)
      if (this.isEdit && (!row.disable || this.allCkb)) {
        this.$emit('HeaderColAll', { row, index })
        let data = {
          type: 'edit_in',
          row: row,
          index: index
        }
        bus.$emit('editTodaySchedule', data)
      }
    },
    copCopy(row, index) {
      if (this.isEdit && (!row.disable || this.allCkb)) {
        this.$emit('copyInsert', { dateInfo: row, index })
      }
    },
    seasonChange() {
      this.$emit('seasonChange', this.seasonVal)
    },
    checkedAllChange() {
      this.$emit('checkedAllChange')
    }
  }
}
</script>

<style lang="scss" scoped>
@import '~@/styles/fullschedule.scss';
.fsc-thead{
  width: 100%;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  .fsc-th-none{
    height: $headerHeight;
    width: $sidebarWidth;
    border-right: solid 1px $borderColor;
    text-align: center;
    line-height: $headerHeight;
  }
}
.fsc-th{
  flex: 1;
  text-align: center;
  border-right: solid 1px $borderColor;
  position: relative;
  overflow: hidden;
  padding:0 8px;
  box-sizing: border-box;
  text-overflow: ellipsis;
  // cursor: pointer;
  user-select:none;
  span.tit{
    position: relative;
    line-height: $headerHeight;
    white-space: nowrap;
  }
  &:last-child{
    border-right: none;
  }
}
</style>
